﻿Type=Activity
Version=3.15
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
	Dim V_XM As String
	Dim V_CH As String
	Dim V_BHID As Int
	Dim V_RYRQ As Int
	
	Dim FBHID As Int
	Dim FHLList As List

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Dim lsvHL As ListView
	
	Dim HttpJobTool As HttpJob
End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("FormBHHLInfo")
	
	Activity.Title = "病人护理信息-"  & V_CH & " " &V_XM 
	
	InitLayOut

End Sub

Sub Activity_Resume
	If FBHID<>V_BHID Then
		RefreshData
	Else
		SetBHHLList(FHLList)
	End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub InitLayOut
	'lsvHL.TwoLinesLayout.Label.TextSize = 25
'	lsvHL.TwoLinesLayout.ItemHeight = 100
'	lsvHL.FastScrollEnabled = True
End Sub

Sub RefreshData
	Dim sURL,sSession,sBHID,sText As String
	
	lsvHL.Clear
	
	sSession = PublicVar.GV_DesTool.Base64encrypt(PublicVar.GV_UserSession)
	
	sBHID = PublicVar.GV_DesTool.Base64encrypt(V_BHID)
	
	sText = "Session=" & sSession & "&BHID=" & sBHID

	sURL = PublicVar.GetServerUrl&"/getbhhlinfo"
	HttpJobTool.Initialize("Job1",Me)
	HttpJobTool.PostString(sURL,sText)
	ProgressDialogShow("正在获取数据，请稍候...")	

End Sub

Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   If Job.Success = True Then
      If Job.JobName = "Job1" Then
				HttpJobSuccess(Job)
      End If
   Else
		HttpJobError(Job)
   End If
   Job.Release
End Sub

Sub HttpJobSuccess(Job As HttpJob)   
	Dim sResult,sCode,sData As String
	Dim mapResult As Map
	
	ProgressDialogHide
	sResult = Job.GetString.Trim
	
	PublicVar.GV_JSonTool.Initialize(sResult)
	mapResult = PublicVar.GV_JSonTool.NextObject
	
	sCode = mapResult.Get("Code")
	If sCode<>"0" Then
		sResult = mapResult.Get("Message")
		ToastMessageShow("获取数据失败"&CRLF &sResult, True)	
		
		PublicVar.CheckSession(sCode)
		Return
	End If
	
	sData = mapResult.Get("Data")
	If sData ="" Then
		ToastMessageShow("获取数据失败"&CRLF &"返回的数据为空", True)	
		Return	
	
	End If
	
	sData = PublicVar.GV_DesTool.Base64decrypt(sData)
	PublicVar.GV_JSonTool.Initialize(sData)
	FHLList = PublicVar.GV_JSonTool.NextArray
	
	SetBHHLList(FHLList)
	FBHID = V_BHID
End Sub

Sub HttpJobError(Job As HttpJob) 
	Dim sMsg As String
	ProgressDialogHide
	
	Log("Error: " & Job.ErrorMessage)
	sMsg = "获取护理数据失败."& CRLF & Job.ErrorMessage 
  ToastMessageShow(sMsg, True)
End Sub

Sub SetBHHLList(lsRecords As List)
	Dim sLine1,sLine2 As String
	Dim iFlag As Int
	Dim mapResult As Map
	
	lsvHL.Clear
	Dim mapHLJL As Map
	mapHLJL.Initialize
	mapHLJL.Put("LX",0)
	lsvHL.AddTwoLines2("体温单","",mapHLJL)
	
	For i = 0 To lsRecords.Size - 1 
		mapResult = lsRecords.Get(i)
		
		sLine1 = mapResult.Get("MC")
		sLine2 = mapResult.Get("HSMC") & " " & mapResult.Get("KSMC") & " "& mapResult.Get("RQ2")
	
		iFlag = mapResult.Get("FLAG")
		Dim mapHLJL As Map
		mapHLJL.Initialize
		If iFlag =1 Then
			mapHLJL.Put("LX",1)
		Else If iFlag =0 Then
			mapHLJL.Put("LX",2)
		End If
		mapHLJL.Put("BLID",mapResult.Get("BLID"))
		lsvHL.AddTwoLines2(sLine1,sLine2,mapHLJL)
		
	Next

End Sub

Sub lsvHL_ItemClick (Position As Int, Value As Object)
	Dim iBLID,iLX As Int
	Dim mapResult As Map
	
	mapResult = Value
	iLX = mapResult.Get("LX")
	
	If iLX =0 Then   '体温单
		BHTWInfo.V_BHID = V_BHID
		BHTWInfo.V_CH = V_CH
		BHTWInfo.V_XM = V_XM
		BHTWInfo.V_RYRQ = V_RYRQ
		
		StartActivity("BHTWInfo")  '体温单信息
		
	Else If iLX =1 OR iLX =2 Then   '1护理记录单 2护理文书
		iBLID = mapResult.Get("BLID")
	
		BHHLNRInfo.V_CH = V_CH
		BHHLNRInfo.V_XM = V_XM
		BHHLNRInfo.V_BHID = V_BHID
		BHHLNRInfo.V_BLID = iBLID
		
		StartActivity("BHHLNRInfo")  
	
	End If
	
	
End Sub


